const url = require('url');
exports.main = (req,res) =>{res.write('It\'s Error Request!!')}
exports.navlist = (app) => {
    var mode = ['os','path','crypto','dns','net','http','v8']
    var html = ''
    for(var k in mode){
        html += '<a href="/node/'+mode[k]+'" style="margin:0 0 0 5px;'+(mode[k] == app? 'color:red;':'')+'">'+mode[k]+'</a>'
    }
    console.log(app)
    if(html) html = '<nav><a href="/index">HOME</a>'+html+'</nav>'
    return html
}
exports.clear = (opt) =>{
    if(typeof(opt) == 'undefined') opt = [__dirname]
    else if(typeof(opt) == 'string') opt = [opt]
    else if(typeof(opt) != 'object') return false
    for(var k in opt){
        try{
            delete require.cache[require.resolve(opt[k])]
        }catch(e){}
    }
}
exports.udata = (u,key) =>{
    var udata = url.parse(u)
    var path = udata['pathname']
    var tmp = path.split('/')
    udata['app'] = tmp[tmp.length-1]
    if(key){
        if(udata[key]) return udata[key]
        return ''
    }
    return udata
}